home *** CD-ROM | disk | FTP | other *** search
/ Programming an RTS Game with Direct3D / Programming an RTS Game with Direct3D.iso / Examples / Chapter 16 / Example 16.1 / sound.h < prev    next >
Encoding:
C/C++ Source or Header  |  2006-06-30  |  1.2 KB  |  66 lines

  1. #ifndef _RTS_SOUND_
  2. #define _RTS_SOUND_
  3.  
  4. #include <vector>
  5. #include <dshow.h>
  6. #include <d3dx9.h>
  7. #include <dmusici.h>
  8. #include <dsound.h>
  9. #include "debug.h"
  10.  
  11. class SOUND;
  12.  
  13. class SOUNDFILE
  14. {
  15.     friend class SOUND;
  16.     public:
  17.         SOUNDFILE();
  18.         ~SOUNDFILE();
  19.         void Load(WCHAR fileName[], SOUND &sound);
  20.  
  21.     private:
  22.         IDirectMusicSegment8 *m_pSegment;
  23. };
  24.  
  25. class SOUND
  26. {
  27.     friend class SOUNDFILE;
  28.     public:
  29.         SOUND();
  30.         ~SOUND();
  31.         void Init(HWND windowHandle);
  32.         
  33.         void PlaySound(int soundID, bool loop);
  34.         void SetMasterVolume(float volume);
  35.         float GetMasterVolume(){return m_masterVolume;}
  36.  
  37.     private:
  38.         IDirectMusicPerformance8 *m_pPerformance;
  39.         IDirectMusicLoader8 *m_pLoader;
  40.  
  41.         float m_masterVolume;
  42.         std::vector<SOUNDFILE*> m_sounds;
  43. };
  44.  
  45. class MP3{
  46.     public:
  47.         MP3();
  48.         ~MP3();
  49.         void Release();
  50.         void Init();
  51.         void LoadSong(WCHAR fName[]);
  52.         void Play();
  53.         void Stop();
  54.         bool IsPlaying();
  55.         void SetVolume(float volume);
  56.         void SetBalance(float balance);
  57.  
  58.     private:
  59.  
  60.         IGraphBuilder *m_pGraphBuilder;
  61.         IMediaControl *m_pMediaControl;
  62.         IMediaPosition *m_pMediaPosition;
  63.         IBasicAudio *m_pBasicAudio;
  64. };
  65.  
  66. #endif